<?php

/**
 * 首页
 * @author Administrator
 *
 */
class IndexAction extends CommonAction {
	
	
	/**
	 * 首页初始化方法
	 */
	public function index() {
		
		$article = D ( 'Article' ); // 文章管理 ：通告咨询和常见问题
		$notice_map = array ('state' => array ('eq', 1 ), 'cid' => array ('eq', 1 ) );		// 通告咨询 文章分类1
		$notice = $article->getdata ( $notice_map, 5 );
		
		$testimonials_map = array ('state' => array ('eq', 1 ), 'cid' => array ('eq', 2 ) );		// 常见问题 文章分类2
		$testimonials = $article->getdata ( $testimonials_map, 5 );
		
		
		$links = D ( 'Links' ); // 友情链接
		$link = $links->getdata (); // 获取友情链接
		
		
		$activity = D('Activity'); //商城活动
		//时间段查询
		$timenow = time();
		$startmap=array(
			'starttime'=>array('elt',$timenow),
			'endtime'=>array('gt',$timenow),
			'state'=>array('eq',1)
		);
		
		$activitydata = $activity-> where($startmap) ->order('endtime desc') ->limit(5)->findAll();
		
		
		//................获取竞拍商品相关信息
		$auction = D ( 'Auction' ); // 竞拍
		
		$todayRecommand = $auction->getRecommendNum ( 'today' ,5); // 获取今天推荐 --获取4个
		
		$where = array(
			 'state' => array ('eq', 1 ),  //进行中的
		     'recommend' => array('neq',1) ,  //不推荐的
		);   
		$now = $auction->getdata ($where,20);    //不是热门推荐的当天竞拍商品--结束时间排序
		
		
		$map ['A.state'] = array ('egt', 2 );
		$end = $auction->getdata ( $map, 6 ); // 获取已结束的商品
		
		
		$idsmap ['state'] = array ('eq', 1 );
		$ids = $auction->getids ( $idsmap );     // 获取所有竞拍中的id集合-----html.html  inibidjs 初始化竞拍属性auction.js
		
		
		
		$this->assign ( 'ids', $ids );     //正在进行中的商品
		$this->assign ( 'now', $now );     //正在竞拍的商品
		$this->assign ( 'end', $end );    //结束的竞标商品
		$this->assign ( 'todayrecommand', $todayRecommand );    //今日热门推荐
		

		$this->assign ( 'link', $link );   //友情连接
			
		$this->assign ( 'notice', $notice );    //通告资讯
		$this->assign ( 'testimonials', $testimonials );  //常见问题
		
		$this->assign('activitydata' ,$activitydata);   //商城活动
		
		
		$this->display ();
	}
	
	
	
	
	/**
	 * 推荐好友连接
	 * Enter description here ...
	 */
	public function invite() {
		$data = Init_GP ( array ('u' ) );  //u是从common.js中到copy_code.html中存放的用户ID
		
		cookie ( 'invite', $data ['u'] );   //通过推荐连接的存放cookie
		
		$this->redirect ( "index" );
	}
	
	
	
	
	
	
}



?>